﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using eduscrum.DAL;
using eduscrum.Models;

namespace eduscrum.Helper
{
    public class Backlog
    {
        private static SystemContext db = new SystemContext();

        public static List<SelectListItem> selectListProductBacklog(int projectID)
        {
            List<SelectListItem> productBacklog = new List<SelectListItem>();
            foreach (UserStory us in db.UserStories.Where(us => us.Sprint == null && us.Project.ProjectID == projectID))
            {
                productBacklog.Add(new SelectListItem { Text = us.Title, Value = us.UserStoryID.ToString() });
            }
            return productBacklog;
        }

        public static List<SelectListItem> selectListSprintBacklog(int sprintID)
        {
            List<SelectListItem> sprintBacklog = new List<SelectListItem>();
            foreach (UserStory us in db.UserStories.Where(us => us.Sprint.SprintID == sprintID))
            {
                sprintBacklog.Add(new SelectListItem { Text = us.Title, Value = us.UserStoryID.ToString() });
            }
            return sprintBacklog;
        }
    }
}